// 1041. 困于环中的机器人/GLL模拟
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> Pa;
const Pa operator+(const Pa& p1, const Pa& p2){
  return {p1.first + p2.first, p1.second + p2.second};
}
const Pa operator-(const Pa& p1, const Pa& p2){
  return {p1.first - p2.first, p1.second - p2.second};
}
bool operator==(const Pa& p1, const Pa& p2){
    return p1.first == p2.first && p1.second == p2.second;
}

class Solution {
public:
  bool isRobotBounded(string instructions) {
    Pa curPos = {0,0};
    // N {0,1}; E {1,0}; S {0,-1}; W {-1,0};
    vector<Pa> vtDir = {{0,1}, {1,0}, {0,-1}, {-1,0}};
    map<char, int> mpDirs = {{'N',0},};
    int curDir = 0; // {N,E,S,W}
    for(auto c:instructions){
      switch (c) {
      case 'G': curPos = curPos + vtDir[curDir];break;
      case 'L': curDir = (curDir+3)%4; break;
      case 'R': curDir = (curDir+1)%4; break;
      default: break;
      }
    }
    return curPos==Pa(0,0) || curDir;
  }
};

int main(){
  Pa p1 = {3,4};
  auto p2 = p1;
  auto p3 = p1 + p2;
  cout<< (p1 == p2) << endl;

  cout << Solution().isRobotBounded("GLLRR") <<endl;
  return 0;
}
